﻿@model CategoryModel
@{
    ViewBag.Title = T("Admin.Catalog.Categories.EditCategoryDetails").Text;
}
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "category-form" }))
{
    <div class="section-header">
        <div class="title">
            @T("Admin.Catalog.Categories.EditCategoryDetails") - @Model.Name 
			<a href='@Url.Action("Index")'>(@T("Admin.Catalog.Categories.BackToList"))</a>
        </div>
        <div class="options">
			@{ Html.RenderWidget("admin_button_toolbar_before"); }

			<button type="submit" name="preview" value="preview" onclick="javascript:openPopup('@Url.RouteUrl("Category", new { SeName = Model.SeName })', true); return false;" class="btn btn-secondary">
				<i class="far fa-eye"></i>
				<span>@T("Admin.Common.Preview")</span>
			</button>
            <button type="submit" name="save" value="save" class="btn btn-warning">
				<i class="fa fa-check"></i>
				<span>@T("Admin.Common.Save")</span>
			</button>
            <button type="submit" name="save" value="save-continue" class="btn btn-secondary">
				<span>@T("Admin.Common.SaveContinue")</span>
			</button>
            <button type="button" id="category-delete" value="category-delete" class="btn btn-danger" data-toggle="modal" data-target="#DeleteCategoryModal">
                <i class="far fa-trash-alt"></i>
				<span>@T("Admin.Common.Delete")</span>
            </button>

			@{ Html.RenderWidget("admin_button_toolbar_after"); }
        </div>
    </div>

    Html.RenderPartial("_CreateOrUpdate", Model);
}

@{Html.SmartStore().Window()
	.Name("DeleteCategoryModal")
	.Title(T("Admin.Catalog.Categories.Delete.Caption"))
	.Size(WindowSize.Medium)
	.Content(@<text>
		<form id="DeleteCategoryForm" method="POST" action="@Url.Action("Delete", "Category")">
			<input type="hidden" name="id" value="@Model.Id" />

			<p>@T("Admin.Catalog.Categories.Delete.Hint")</p>

			<div class="form-check">
				<input type="radio" class="form-check-input" id="deleteType_1" name="deleteType" value="resetparent" checked="checked" />
				<label for="deleteType_1" class="form-check-label">
					@T("Admin.Catalog.Categories.Delete.ResetParentOfChilds")
				</label>
			</div>
			<div class="form-check mt-1">
				<input type="radio" class="form-check-input" id="deleteType_2" name="deleteType" value="deletechilds" />
				<label for="deleteType_2" class="form-check-label">
					@T("Admin.Catalog.Categories.Delete.DeleteChilds")
				</label>
			</div>
		</form>
	</text>)
	.FooterContent(@<text>
		<button class="btn btn-secondary" data-dismiss="modal">
			<span>@T("Common.Cancel")</span>
		</button>
		<button class="btn btn-danger" data-dismiss="modal" onclick="$('#DeleteCategoryForm').submit();">
			<span>@T("Common.OK")</span>
		</button>
	</text>)
	.Render();
}
